<template>
  <div class="container">
    <a-table class="table" :rowKey="row => row.id" :dataSource="list">
      <a-table-column title="用户ID" width="30px">
        <template slot-scope="row">
          <div v-if="row.user">{{row.user.id}}</div>
        </template>
      </a-table-column>
      <a-table-column
        title="平台用户"
        key="name"
        width="60px"
      >
        <template slot-scope="row">
          <span v-if="row.user">
            <img :src="row.user.headimg" class="headimg">
            {{ row.user.name }}
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.status === 2">已拉黑</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_rb === 1">马甲</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_rb2 === 1">主播</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_liu === 1">老六</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_nopay === 1">禁付</a-tag>
            <a-tag color="blue" style="margin-left:10px;" v-if="row.user.click_id">微广</a-tag>
          </span>
        </template>
      </a-table-column>
      <a-table-column title="手机号" width="30px">
        <template slot-scope="row">
          <div v-if="row.user">{{row.user.phone}}</div>
        </template>
      </a-table-column>

      <a-table-column title="订单" width="80px">
        <template slot-scope="row">
          <div>{{ row.title }}</div>
          <div>{{ row.number }}</div>
        </template>
      </a-table-column>
      <a-table-column title="优惠金额" width="10px">
        <template slot-scope="row">
          <div>{{ row.coupon_discount / 100 }} 元</div>
        </template>
      </a-table-column>
      <a-table-column title="使用时间" width="80px">
        <template slot-scope="row">
          <div>{{row.created_at}}</div>
        </template>
      </a-table-column>
      
    </a-table>


  </div>
</template>

<script>
  import { getCouponLog } from '@/api/visitors'
  import moment from 'moment'

  export default {
    components: {

    },
    data() {
      return {
        info: {},
        list: []
      }
    },
    computed: {
    },
    props: {
      coupon_id: 0
    },
    created() {
      this.fetchData();
    },
    filters: {
      formatDate (value) {
        return value ? moment(value).fromNow() : ''
      },
      formatDate2 (value) {
        return value ? moment(value).format('YYYY-MM-DD') : ''
      }
    },
    mounted() {},
    watch: {},
    methods: {
       fetchData () {
        getCouponLog({
          coupon_id:this.coupon_id
        }).then(res => {
          this.list = res.data.list
        })
      },
      cancel() {
        this.$router.back(-1)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .headimg {
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }


  .form-container {
    padding-bottom: 120px;
  }

  .container {
    .btn {
      margin-right: 30px;
    }
  }

  .tips-c {
    margin-bottom: 20px;
    font-weight: 500;
  }
</style>
